import upload from '@/utils/upload'
import request from '@/utils/request'

/**
 * 上传图片到成本模块的图片存储，返回原始存储路径
 * @param {String} filePath uni.chooseImage 等返回的临时文件路径
 * @returns {Promise<{code:number,msg:string,data:any}>}
 */
export function uploadConstructionImage(filePath) {
  if (!filePath) {
    return Promise.reject(new Error('缺少可上传的文件路径'))
  }
  return upload({
    url: '/cost/imageStorage/upDataImage',
    name: 'file',
    filePath
  })
}

/**
 * 删除已上传图片（当前仅在需要时调用）
 * @param {Object} data
 */
export function deleteConstructionImage(data) {
  return request({
    url: '/cost/imageStorage/delUpDataImage',
    method: 'post',
    data
  })
}

